package com.lyf.shop.services.Impl;

import com.lyf.shop.dao.Impl.TypeDaoImpl;
import com.lyf.shop.dao.TypeDao;
import com.lyf.shop.entity.Type;
import com.lyf.shop.services.TypeService;
import com.lyf.shop.util.StrUtils;

import java.sql.SQLException;
import java.util.List;

public class TypeServiceImpl implements TypeService {
    private TypeDao typeDao = new TypeDaoImpl();
    @Override
    public List<Type> getAll() {
        try {
            return  typeDao.getAll();
        } catch (SQLException throwables) {
            throwables.printStackTrace();
            return null;
        }
    }

    @Override
    public List<Type> getAllByKey(String tname) {
        try {
            return typeDao.getAllByKey(tname);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        return null;
    }

    @Override
    public int addType(String tname, String tinfo) {
        if(StrUtils.empty(tname,tinfo)){
            try {
                return typeDao.addType(tname,tinfo);
            } catch (SQLException throwables) {
                throwables.printStackTrace();
            }
        }
        return 0;
    }

}
